Add more structure to the warnings returned from crates.io publish
authorCarol (Nichols || Goulding) <carol.nichols@gmail.com>
Mon, 5 Dec 2016 17:36:44 +0000 (12:36 -0500)
committerCarol (Nichols || Goulding) <carol.nichols@gmail.com>
Mon, 5 Dec 2016 17:36:44 +0000 (12:36 -0500)
src/cargo/ops/registry.rs
src/crates-io/lib.rs

index 2b4447609591c7a5eb905fb579f2971a00434567..4c9bad817ac30b702ae1e39370ed6919375218bd 100644 (file)
@@ -151,13 +151,13 @@ fn transmit(config: &Config,
     }, tarball);
 
     match publish {
-        Ok(invalid_categories) => {
-            if !invalid_categories.is_empty() {
+        Ok(warnings) => {
+            if !warnings.invalid_categories.is_empty() {
                 let msg = format!("\
                     the following are not valid category slugs and were \
                     ignored: {}. Please see https://crates.io/category_slugs \
                     for the list of all category slugs. \
-                    ", invalid_categories.join(", "));
+                    ", warnings.invalid_categories.join(", "));
                 config.shell().warn(&msg)?;
             }
             Ok(())
index e35d824403380c389dc8d9212df10a6939253798..00637be3dc29cd9ffb6802adc63573159f177198 100644 (file)
@@ -111,6 +111,10 @@ pub struct User {
     pub name: Option<String>,
 }
 
+pub struct Warnings {
+    pub invalid_categories: Vec<String>,
+}
+
 #[derive(RustcDecodable)] struct R { ok: bool }
 #[derive(RustcDecodable)] struct ApiErrorList { errors: Vec<ApiError> }
 #[derive(RustcDecodable)] struct ApiError { detail: String }
@@ -155,7 +159,7 @@ impl Registry {
     }
 
     pub fn publish(&mut self, krate: &NewCrate, tarball: &File)
-                   -> Result<Vec<String>> {
+                   -> Result<Warnings> {
         let json = json::encode(krate)?;
         // Prepare the body. The format of the upload request is:
         //
@@ -215,7 +219,7 @@ impl Registry {
                     x.iter().flat_map(Json::as_string).map(Into::into).collect()
                 })
                 .unwrap_or_else(Vec::new);
-        Ok(invalid_categories)
+        Ok(Warnings { invalid_categories: invalid_categories })
     }
 
     pub fn search(&mut self, query: &str, limit: u8) -> Result<(Vec<Crate>, u32)> {